package ca.ubc.icapture.genapha.forms;

import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.ValidatorForm;

/**
 *
 * @author phan
 */
public class MoveGeneSnpForm extends ValidatorForm {

    private Integer searchSelect;
    private String searchText;
    private String submitType;
    private ArrayList<String> geneSetLookUp = null;
    private String geneSet;
    private String snpSet;
    private ArrayList<String> snpSetLookUp = null;
    private ArrayList<String> errors = null;

    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        searchText = "";
        submitType = "";
    }

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = super.validate(mapping, request);

        if (submitType.equalsIgnoreCase("Search")) {
            boolean isValid = true;
            if (searchText.isEmpty()) {
                isValid = false;
            }
            if (!isValid) {
                errors.add("search", new ActionMessage("search.error"));
            }
        }

        return errors;
    }

    /**
     * @return the searchSelect
     */
    public Integer getSearchSelect() {
        return searchSelect;
    }

    /**
     * @param searchSelect the searchSelect to set
     */
    public void setSearchSelect(Integer searchSelect) {
        this.searchSelect = searchSelect;
    }

    /**
     * @return the searchText
     */
    public String getSearchText() {
        return searchText;
    }

    /**
     * @param searchText the searchText to set
     */
    public void setSearchText(String searchText) {
        this.searchText = searchText;
    }

    /**
     * @return the submitType
     */
    public String getSubmitType() {
        return submitType;
    }

    /**
     * @param submitType the submitType to set
     */
    public void setSubmitType(String submitType) {
        this.submitType = submitType;
    }

    public ArrayList<String> getGeneSetLookUp(){
        return geneSetLookUp;
    }

    public void setGeneSetLookUp(ArrayList<String> geneSetLookUp){
        this.geneSetLookUp = geneSetLookUp;
    }

    public String getGeneSet(){
        return geneSet;
    }

    public void setGeneSet(String geneSet){
        this.geneSet = geneSet;
    }

    public ArrayList<String> getSnpSetLookUp(){
        return snpSetLookUp;
    }

    public void setSnpSetLookUp(ArrayList<String> geneSetLookUp){
        this.snpSetLookUp = geneSetLookUp;
    }

    public String getSnpSet(){
        return snpSet;
    }

    public void setSnpSet(String snpSet){
        this.snpSet = snpSet;
    }

    public ArrayList<String> getErrors(){
        return errors;
    }

    public void setErrors(ArrayList<String> errors){
        this.errors = errors;
    }
}
